package com.cac.demo.controller.gkinterface;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cac.demo.controller.compressedFiles.CompressedFilesEditor;
import com.cac.demo.dao.cemopHandoverForm.CemopDeliverPlanDao;
import com.cac.demo.dao.gkinterface.ReCallWzDao;
import com.cac.demo.dao.materialScan.WmsDeliverPlanDao;
import com.cac.demo.newCode.cemop.dto.CemopInitiateCoordinationDTO;
import com.cac.demo.newCode.cemop.service.CemopService;
import com.cac.demo.service.CallInterface.CallInterfaceService;
import com.cac.demo.service.FinProReceive.FinProReceiveSearchService;
import com.cac.demo.service.gkinterface.ReCallWzService;
import com.cac.demo.service.gkinterface.WorkService;
import com.cac.demo.service.partReceive.PartReceiveService;
import com.cac.demo.util.CreatMsgId;
import com.cac.demo.util.ExceptionToStirng;
import com.cac.demo.util.adapter.ComUtil;
import com.cac.demo.util.adapter.ResponseMsg;
import lombok.extern.slf4j.Slf4j;
import net.logstash.logback.encoder.org.apache.commons.lang.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;

@Slf4j
@RestController
@RequestMapping("TestCallWz")
@EnableScheduling
public class ReCallWz {
    @Autowired
    private WmsDeliverPlanDao wmsDeliverPlanDao;
    @Autowired
    private CallInterfaceService callInterfaceService;
    @Autowired
    private Environment environment;
    @Autowired
    private ReCallWzDao testCallWzDao;
    @Autowired
    private FinProReceiveSearchService finProReceiveSearchService;
    @Autowired
    private PartReceiveService partReceiveService;
    @Autowired
    private WorkService workService;
    @Autowired
    private ReCallWzService testCallWzService;
    @Autowired
    private CompressedFilesEditor compressedFilesEditor;
    @Autowired
    private CemopDeliverPlanDao cemopDeliverPlanDao;
    @Autowired
    private CemopService cemopService;

    /***
     * 重新推送erp物料入库信息接口  推送台账
     * */
    @PostMapping("reCallToErp")
    public String reCallToErp(@RequestBody HashMap map) {
        List<HashMap> lists = (List<HashMap>) map.get("datas");
        //如果类型是从配置表传递数据
        if ("table".equals(map.get("type"))) {
            lists = testCallWzDao.queryWmsDeliveryPlanIds();
        }
        //重新反馈erp交接单信息
        //查询交接单  台账数量为0的不管
        for (HashMap list : lists) {
            HashMap issuedTest = new HashMap();

            HashMap delivery = testCallWzDao.queryItemInventory(list);
            if (delivery == null || delivery.isEmpty()) {
                continue;
            }
            if (!delivery.get("deliveryStatus").equals("6"))
            {
                return "条码"+delivery.get("barcode")+"未完全接收";
            }

            log.info("重推台账:" + list.toString());
            try {
                String func = list.get("func").toString();
                HashMap senBData = new HashMap();
                issuedTest.put("id", ComUtil.getId());
                JSONObject headersMap = new JSONObject();
                String CemopUrl = environment.getProperty("cemopUrl.receivePlan");
                JSONArray jsonArray = new JSONArray();
                //定义json对象存储数据，打包发送到Cemop
                JSONObject json = new JSONObject();
                json.put("userId", delivery.get("receiveEmpCode")); //接收人工号
                json.put("momWmsDeliveryPlanId", delivery.get("wmsDeliveryPlanId"));//交接单id
                json.put("momWmsItemInventoryId", delivery.get("wmsItemInventoryId"));//台账id
                jsonArray.add(json);
                //将json转换为zip文件
                System.out.println("====================接收入库重推到Cemop=====================："+jsonArray);
                String zipUrl = compressedFilesEditor.generateZip(jsonArray.toString());
                compressedFilesEditor.fileSend(jsonArray.toString(),zipUrl, CemopUrl,"重新推送erp物料入库信息接口");
            } catch (Exception e) {
                issuedTest.put("retCode", "0");
                String rslt = ExceptionToStirng.getExceptionToString(e);
                issuedTest.put("result", rslt.substring(0, 3900));
                issuedTest.put("remark", "recall");
                workService.issuedTest(issuedTest);
                e.printStackTrace();
            }
        }
        log.info("调用结束》》》》》》》》》》》》》》》》》");
        return "执行结束";
    }
    /**
     * 重新推送erp移交信息  推送移交
     **/
    @PostMapping("reCallChangeTransfer")
    public String reCallChangeTransfer(@RequestBody HashMap map) {
        List<HashMap> lists = (List<HashMap>) map.get("datas");
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String userId = (String) request.getSession().getAttribute("account");
        //如果类型是从配置表传递数据
        if ("table".equals(map.get("type"))) {
            lists = testCallWzDao.queryWmsDeliveryPlanIds();
        }
        for (HashMap data : lists) {
            HashMap issuedTest = new HashMap();
            try {
                String CemopUrl = environment.getProperty("cemopUrl.deliveryPlan");
                String logisticscode = environment.getProperty("cemopinfo.logisticscode");
                String logisticsName = environment.getProperty("cemopinfo.logisticsName");
                //定义json对象存储数据，打包发送到Cemop
                JSONArray jsonArray = new JSONArray();
                JSONObject json = new JSONObject();
                String id = (String) data.get("wmsDeliveryPlanId");
                String shop = cemopDeliverPlanDao.getShopByid(id).get(0);

                json.put("momWmsDeliveryPlanId", id);  //交接单id
                json.put("logisticscode", logisticscode);  //物流区域编码
                json.put("logisticsName", logisticsName);      //物流区域名称
                json.put("empCode", data.get("deliveryEmpCode"));      //移交人工号
                json.put("userId", userId);               //操作人工号
                json.put("shop", shop);      //shop
                json.put("barCode", data.get("barcode"));      //barcode
                jsonArray.add(json);
                System.out.println("==================重推扫码移交================:"+jsonArray.toString());
                String path = compressedFilesEditor.generateZip(jsonArray.toString()); //将json转换为zip文件 url
                compressedFilesEditor.fileSend(jsonArray.toString(),path, CemopUrl,"重推扫码移交");
            } catch (Exception e) {
                issuedTest.put("retCode", "0");
                String rslt = ExceptionToStirng.getExceptionToString(e);
                issuedTest.put("result", rslt.substring(0, 3900));
                issuedTest.put("remark", "recall");
                workService.issuedTest(issuedTest);
            }

        }
        return "执行结束";
    }


    //重新推送回退 xiaojian 4-24
    @PostMapping("reCallScanBack")
    public HashMap reCallScanBack(@RequestBody HashMap map) {
        HashMap hashMap = new HashMap();
        //获取前端传来的值
        List<HashMap> lists = (List<HashMap>) map.get("datas");
        int i = 0;
        for (HashMap data : lists) {
            String deliveryStatus = (String) data.get("deliveryStatus");
            if (!deliveryStatus.equals("已退回")) {
                i++;
            }
        }
        if (i > 0) {
            hashMap.put("alert", "请确保所有数据为已退回状态");
            hashMap.put("retCode", "201");
            return hashMap;
        }
        for (HashMap data : lists) {
            HashMap issuedTest = new HashMap();
            issuedTest.put("id", ComUtil.getId());
            try {
                //获得扫码退回业务数据
                String parameters = testCallWzService.getscanBackBData(data, issuedTest);
                String code = "sendBData";
                String sendScenario = "扫码退回";
                String name = "两网传输-发送业务数据";
                long beginTime = System.currentTimeMillis();
                log.info("======开始时间=======" + beginTime);
                //调用两网传输接口传递业务数据
                callInterfaceService.sendBData(code, name, parameters, sendScenario);
                long endTime = System.currentTimeMillis();
                log.info("======消耗时间=======" + (endTime - beginTime) + "ms");
                issuedTest.put("retCode", "1");
                issuedTest.put("result", "操作成功");
                issuedTest.put("remark", "recall");
                //生成外部接口调用日志
                workService.issuedTest(issuedTest);
            } catch (Exception e) {
                issuedTest.put("retCode", "0");
                String rslt = ExceptionToStirng.getExceptionToString(e);
                issuedTest.put("result", rslt.substring(0, 3900));
                issuedTest.put("remark", "recall");
                //生成外部接口调用日志
                workService.issuedTest(issuedTest);
            }
        }
        hashMap.put("alert", "执行结束");
        hashMap.put("retCode", "200");
        return hashMap;
    }

    //重新推送协调 xiaojian 4-24
    @PostMapping("reCallCoordinate")
    public HashMap reCallCoordinate(@RequestBody HashMap map) {
        HashMap hashMap = new HashMap();
        //获取前端传来的值
        List<HashMap> lists = (List<HashMap>) map.get("datas");
        int i = 0;
        for (HashMap data : lists) {
            HashMap status = testCallWzDao.coordinateStatusRecall(data);
            if (status == null) {
                i++;
            } else {
                if (status.get("status").equals("0")) {
                    i++;
                }
            }
        }
        if (i > 0) {
            hashMap.put("alert", "请确保所有数据已创建协调单并提交");
            hashMap.put("retCode", "201");
            return hashMap;
        }
        for (HashMap data : lists) {
            HashMap issuedTest = new HashMap();
            issuedTest.put("id", ComUtil.getId());
            try {
                //获得提交协调单业务数据
                HashMap parameters = testCallWzService.getCoordinateDatas(data, issuedTest);
                CemopInitiateCoordinationDTO cemopInitiateCoordinationDTO = new CemopInitiateCoordinationDTO();
                cemopInitiateCoordinationDTO.setMomWmsDeliveryCoordinateId(parameters.get("wmsCoordinateInfoId").toString());
                cemopInitiateCoordinationDTO.setMomWmsDeliveryPlanId(parameters.get("wmsPreDeliveryPlanId").toString());
                cemopInitiateCoordinationDTO.setProblemType(parameters.get("coordinateSort").toString());
                cemopInitiateCoordinationDTO.setProblemContent(parameters.get("coordinateDesc").toString());
                cemopInitiateCoordinationDTO.setPysdstIdntfcNo(parameters.get("barcode").toString());
                cemopInitiateCoordinationDTO.setUserId(parameters.get("opUserCode").toString());
                cemopService.sendInitiateCoordinationData(cemopInitiateCoordinationDTO);
                issuedTest.put("retCode", "1");
                issuedTest.put("result", "操作成功");
                issuedTest.put("remark", "recall");
                //生成外部接口调用日志
                workService.issuedTest(issuedTest);
            } catch (Exception e) {
                issuedTest.put("retCode", "0");
                String rslt =ExceptionToStirng.getExceptionToString(e);
                issuedTest.put("result", rslt.substring(0, 3900));
                issuedTest.put("remark", "recall");
                //生成外部接口调用日志
                workService.issuedTest(issuedTest);
            }
        }
        hashMap.put("alert", "执行结束");
        hashMap.put("retCode", "200");
        return hashMap;
    }

    //xiaojian 5-8 修改交接单状态
    @PostMapping("updateDeliveryStatus")
    public HashMap updateDeliveryStatus(@RequestBody HashMap map) {
        HashMap hashMap = new HashMap();
        List<HashMap> datas = (List<HashMap>) map.get("datas");
        for (HashMap data : datas) {
            int count = testCallWzDao.updateDeliveryStatus(data);
            if (count == 0) {
                hashMap.put("alert", "该条码只存在一条状态为已移交的交接单，无法进行废除！");
                hashMap.put("retCode", "201");
                return hashMap;
            }
        }
        hashMap.put("alert", "成功废除一条交接单！");
        hashMap.put("retCode", "200");
        return hashMap;
    }

    //xiaojian 7-26 重推分拣占用信息到ERP
    @PostMapping("recallOutAllotToERP")
    public HashMap recallOutAllotToERP(@RequestBody HashMap inMap) {
        HashMap retHashMap = new HashMap();
        HashMap map = testCallWzDao.recallOutAllotToERP(inMap);
        JSONObject headersMap = new JSONObject();
        String msgId = CreatMsgId.getMsgId();
        //获取func
        headersMap.put("func", environment.getProperty("doReturnErp.sortOccupy.func"));
        headersMap.put("msgId", msgId);
        //分拣占用接口所需参数
        map.put("taskNo", "");
        map.put("recHrDeptId", "");

        JSONObject data = new JSONObject(map);
        headersMap.put("data", data);
        String headersmap = headersMap.toJSONString();

        //对已经转换成字符串的数据进行加密
        final Base64.Encoder encoder = Base64.getEncoder();
        String BData = encoder.encodeToString(headersmap.getBytes());

        log.info("==========================工控网上传_重推分拣占用============================");
        //工控网上传数据
        HashMap issuedTest = new HashMap();
        issuedTest.put("BData", headersmap);
        issuedTest.put("msgId", msgId);
        issuedTest.put("type", headersMap.get("func"));

        log.info("工控网上传程序后台日志:>>>>>>>>>>>>>>>>>>>>>>>>>issuedParameters:" + issuedTest.toString());
        log.info("==========================工控网上传_重推分拣占用============================");
        workService.issuedTest(issuedTest);
        String code = "sendBData";
        String sendScenario = "分拣占用";
        String name = "两网传输-发送业务数据";
        long beginTime = System.currentTimeMillis();
        log.info("======开始时间=======" + beginTime);
        callInterfaceService.sendBData(code, name, BData, sendScenario);
        long endTime = System.currentTimeMillis();
        log.info("======消耗时间=======" + (endTime - beginTime) + "ms");

        retHashMap.put("retMsg", "成功推送分拣占用信息！");
        retHashMap.put("retCode", "200");
        return retHashMap;
    }


    //重推标准件交接单  没有使用
    @GetMapping("recallBzjDelivery")
    public String recallBzjDelivery() {
        log.info("此方法已不在使用");
        StringBuffer sb = new StringBuffer();
        String bzjCodeType = "BZJCK";
        List<HashMap> barcodes = testCallWzDao.queryBzjDeliveryByTable();
        String barcodeType = "BZJ";
        long beginTime = System.currentTimeMillis();
        for (HashMap barco : barcodes) {
            String msgIdnew = CreatMsgId.getMsgId();
            String parameters = testCallWzService.scanDelivery(barco.get("barcode").toString(), msgIdnew,
                    barcodeType, bzjCodeType, barco.get("wmsDeliveryPlanId").toString());
            String code = "sendBData";
            String sendScenario = "零件移交";
            String name = "两网传输-发送业务数据";
            callInterfaceService.sendBData(code, name, parameters, sendScenario);
        }
        long endTime = System.currentTimeMillis();
        sb.append((endTime - beginTime) / 1000).append("秒,推送完毕");
        return sb.toString();
    }

    //重推标准件台账  此方法不知道在哪使用，推送台账统一用的上面第一个方法
    @GetMapping("recallBzjInventory")
    public String recallBzjInventory() {
        log.info("此方法已不在使用");
        StringBuffer sb = new StringBuffer();
        JSONObject headersMap = new JSONObject();
        HashMap senBData = new HashMap();
        HashMap issuedTest = new HashMap();
        long beginTime = System.currentTimeMillis();
        log.info("======开始时间=======" + beginTime);
        List<HashMap> list = testCallWzDao.queryBzjInventoryByTable();
        for (HashMap lst : list) {
            headersMap.put("func", environment.getProperty("doReturnErp.scanRecieveBzj.func"));
            senBData.put("wmsPreDeliveryPlanId", lst.get("wmsDeliveryPlanId"));
            senBData.put("wmsItemInventoryId", lst.get("wmsItemInventoryId"));
            senBData.put("remark", Objects.isNull(lst.get("remark")) ? " " : lst.get("remark"));
            senBData.put("locatorNo", environment.getProperty("doReturnErp.locatorNo.func"));
            senBData.put("recieveQty", lst.get("deliveryQty"));//此处应该用移交数量
            senBData.put("opUserCode", lst.get("opUserCode"));
            senBData.put("userIp", lst.get("ip"));
            JSONObject data = new JSONObject(senBData);
            headersMap.put("data", data);
            String msgId = CreatMsgId.getMsgId();
            headersMap.put("msgId", msgId);
            issuedTest.put("BData", headersMap.toJSONString());
            issuedTest.put("msgId", msgId);
            log.info("加密前BData：" + headersMap.toJSONString());
            log.info("工控网上传程序后台日志:>>>>>>>>>>>>>>>>>>>>>>>>>issuedParameters:" + issuedTest.toString());
            workService.issuedTest(issuedTest);
            //对已经转换成字符串的数据进行加密
            final Base64.Encoder encoder = Base64.getEncoder();
            String BData = encoder.encodeToString(headersMap.toJSONString().getBytes());
            log.info("加密后BData：" + BData);
            String parameters = BData;
            String code = "sendBData";
            String sendScenario = "物料接收入库";
            String name = "两网传输-发送业务数据";
            callInterfaceService.sendBData(code, name, parameters, sendScenario);
        }
        long endTime = System.currentTimeMillis();
        sb.append((endTime - beginTime) / 1000).append("秒,推送完毕");
        return sb.toString();
    }

    @GetMapping("makeMaterialCheck")
    public String makeMaterialCheck() {
        try {
            log.info("前台推送出库");
            testCallWzService.makeMaterialCheck();
        } catch (Exception e) {
            e.printStackTrace();
            return "推送erp出库失败";
        }
        return "推送erp出库完成";
    }

    @GetMapping("sendOccupyInfo")
    public String sendOccupyInfo() {
        log.info("推送占用信息【不生成占用信息】");
        testCallWzService.sendSortOccupy();
        return null;
    }
    //    /***
//     * 重新推送erp物料入库信息接口  推送台账
//     * */
//    @PostMapping("reCallToErp")
//    public String reCallToErp(@RequestBody HashMap map) {
//        List<HashMap> lists = (List<HashMap>) map.get("datas");
//        //如果类型是从配置表传递数据
//        if ("table".equals(map.get("type"))) {
//            lists = testCallWzDao.queryWmsDeliveryPlanIds();
//        }
//        //重新反馈erp交接单信息
//        //查询交接单  台账数量为0的不管
//        for (HashMap list : lists) {
//            HashMap issuedTest = new HashMap();
//
//            HashMap delivery = testCallWzDao.queryItemInventory(list);
//            if (delivery == null || delivery.isEmpty()) {
//                continue;
//            }
//
//            log.info("111111111111:" + list.toString());
//            try {
//                String func = list.get("func").toString();
//                HashMap senBData = new HashMap();
//                issuedTest.put("id", ComUtil.getId());
//                JSONObject headersMap = new JSONObject();
//                if (func.equals("ERP-101-preConfirmCp")) {
//                    HashMap hashMap = finProReceiveSearchService.searchCoordinate((String) delivery.get("barcode"));
//                    if (Objects.isNull(hashMap)) {
//                        headersMap.put("func", environment.getProperty("doReturnErp.doCpDeliveryReceiveErp.func"));
//                    } else {
//                        String WMS_DELIVERY_COORDINATE_ID = (String) hashMap.get("WMS_DELIVERY_COORDINATE_ID");
//                        senBData.put("wmsCoordinateInfoId", WMS_DELIVERY_COORDINATE_ID);
//                        headersMap.put("func", environment.getProperty("doReturnErp.scanZeroReceiveCp.func"));
//                    }
//
//                } else if (func.equals("ERP-101-preConfirmLj")) {
//                    HashMap hashMap = partReceiveService.searchCoordinate((String) delivery.get("barcode"));
//                    if (Objects.isNull(hashMap)) {
//                        headersMap.put("func", environment.getProperty("doReturnErp.materialReviceRetrunErp.func"));
//                        senBData.put("sealDate", delivery.get("sealDate") == null ? " " : delivery.get("sealDate"));
//                        senBData.put("ensureDate", delivery.get("ensureDate") == null ? " " : delivery.get("ensureDate"));
//                        senBData.put("maxStorageDate", delivery.get("maxStorageDate") == null ? " " : delivery.get("maxStorageDate"));
//                        senBData.put("recieveNote", delivery.get("recieveNote") == null ? " " : delivery.get("recieveNote"));
//                    } else {
//                        String WMS_DELIVERY_COORDINATE_ID = (String) hashMap.get("WMS_DELIVERY_COORDINATE_ID");
//                        senBData.put("wmsCoordinateInfoId", WMS_DELIVERY_COORDINATE_ID);
//                        headersMap.put("func", environment.getProperty("doReturnErp.scanZeroReceiveLj.func"));
//                    }
//
//                } else if (func.equals("ERP-101-preConfirmBzj")) {
//                    headersMap.put("func", "101-ERP-scanRecieveBzj");
//                }
//                //查询是否无库存交接
//                HashMap ret = wmsDeliverPlanDao.searchDeliveryType(delivery.get("wmsDeliveryPlanId").toString());
////                String requireShop = wmsDeliverPlanDao.searchRequireShopByBarcode((String) delivery.get("barcode"));
//            /*    if (!Objects.isNull(ret) && ret.containsKey("attribute5Desc")) {
//                    if ("NOINV".equals(ret.get("attribute5Desc"))) {
//                        if("143".equals(requireShop)){
//                            senBData.put("inventoryCode", "101-FJZX143");
//                        }else{
//                            senBData.put("inventoryCode", "101-FJZX");
//                        }
//
//                    }
//                }*/
//                if ("143".equals(ret.get("requireShop"))) {
//                    senBData.put("inventoryCode", "101-FJZX143");
//                    if (delivery.get("receiveEmpCode") != null && delivery.get("receiveEmpCode") != null) {
//                        senBData.put("opUserCode", delivery.get("receiveEmpCode"));
//                    } else {
//                        senBData.put("opUserCode", "486809");
//                    }
//                } else {
//                    senBData.put("inventoryCode", "101-FJZX");
//                    if (delivery.get("receiveEmpCode") != null && delivery.get("receiveEmpCode") != null) {
//                        senBData.put("opUserCode", delivery.get("receiveEmpCode"));
//                    } else {
//                        senBData.put("opUserCode", "488831");
//                    }
//                }
//                senBData.put("wmsPreDeliveryPlanId", delivery.get("wmsDeliveryPlanId"));
//                senBData.put("wmsItemInventoryId", delivery.get("wmsItemInventoryId"));
//                senBData.put("locatorNo", environment.getProperty("doReturnErp.locatorNo.func"));
//                senBData.put("recieveQty", delivery.get("deliveryQty"));
//

    /// /                senBData.put("opUserCode", "383020");//操作人，此处写死，就用这个人
//                senBData.put("userIp", "172.53.29.58");
//                JSONObject data = new JSONObject(senBData);
//                headersMap.put("data", data);
//                String msgId = CreatMsgId.getMsgId();
//                headersMap.put("msgId", msgId);
//                log.info("加密前BData：" + headersMap.toJSONString());
//                //对已经转换成字符串的数据进行加密
//                final Base64.Encoder encoder = Base64.getEncoder();
//                String BData = encoder.encodeToString(headersMap.toJSONString().getBytes());
//                log.info("加密后BData：" + BData);
//                String parameters = BData;
//                String code = "sendBData";
//                String sendScenario = "物料接收入库";
//                String name = "两网传输-发送业务数据";
//                long beginTime = System.currentTimeMillis();
//                callInterfaceService.sendBData(code, name, parameters, sendScenario);
//                long endTime = System.currentTimeMillis();
//                log.info("======消耗时间=======" + (endTime - beginTime) + "ms");
//                //日志表记录
//                issuedTest.put("type", headersMap.get("func"));
//                issuedTest.put("BData", headersMap.toString());
//                issuedTest.put("retCode", "1");
//                issuedTest.put("result", "操作成功");
//                issuedTest.put("remark", "recall");
//                issuedTest.put("msgId", msgId);
//                issuedTest.put("businessVal", delivery.get("wmsItemInventoryId"));
//                issuedTest.put("businessCol", "wms_item_inventory_id");
//                issuedTest.put("businessTab", "wms_item_inventory");
//                workService.issuedTest(issuedTest);
//                //更新批量推送表状态
//                testCallWzDao.updateMsRecallTabStatus(list);
//            } catch (Exception e) {
//                issuedTest.put("retCode", "0");
//                String rslt = ExceptionToStirng.getExceptionToString(e);
//                issuedTest.put("result", rslt.substring(0, 3900));
//                issuedTest.put("remark", "recall");
//                workService.issuedTest(issuedTest);
//                e.printStackTrace();
//            }
//        }
//        log.info("调用结束》》》》》》》》》》》》》》》》》");
//        return "执行结束";
//    }
//    /**
//     * 重新推送erp移交信息  推送移交
//     **/
//    @PostMapping("reCallChangeTransfer")
//    public String reCallChangeTransfer(@RequestBody HashMap map) {
//        List<HashMap> lists = (List<HashMap>) map.get("datas");
//        //如果类型是从配置表传递数据
//        if ("table".equals(map.get("type"))) {
//            lists = testCallWzDao.queryWmsDeliveryPlanIds();
//        }
//        for (HashMap data : lists) {
//            HashMap issuedTest = new HashMap();
//            try {
//                ResponseMsg responseMsg = testCallWzService.getBData(data, issuedTest);
//                String parameters = null;
//                if ("201".equals(responseMsg.getRetCode())) {
//                    issuedTest.put("retCode", "0");
//                    String rslt = responseMsg.getResponseBody().toString();
//                    issuedTest.put("result", rslt);
//                    issuedTest.put("remark", "recall");
//                    workService.issuedTest(issuedTest);
//                    return responseMsg.getResponseBody().toString();
//                } else {
//                    parameters = responseMsg.getResponseBody().toString();
//                }
//                String code = "sendBData";
//                String sendScenario = "重推移交";
//                String name = "两网传输-发送业务数据";
//                long beginTime = System.currentTimeMillis();
//                log.info("======开始时间=======" + beginTime);
//                callInterfaceService.sendBData(code, name, parameters, sendScenario);
//                long endTime = System.currentTimeMillis();
//                log.info("======消耗时间=======" + (endTime - beginTime) + "ms");
//                issuedTest.put("retCode", "1");
//                issuedTest.put("result", "操作成功");
//                issuedTest.put("remark", "recall");
//                issuedTest.put("businessVal", data.get("wmsDeliveryPlanId"));
//                issuedTest.put("businessCol", "wms_delivery_plan_id");
//                issuedTest.put("businessTab", "wms_delivery_plan");
//                workService.issuedTest(issuedTest);
//                //更新批量推送表状态
//                testCallWzDao.updateMsRecallTabStatus(data);
//            } catch (Exception e) {
//                issuedTest.put("retCode", "0");
//                String rslt = ExceptionToStirng.getExceptionToString(e);
//                issuedTest.put("result", rslt.substring(0, 3900));
//                issuedTest.put("remark", "recall");
//                workService.issuedTest(issuedTest);
//
//            }
//
//        }
//        return "执行结束";
//    }

}
